Title Banner


Technotes


System Error Handler Q&As



Technote OS 525December 1992



Revised by: Developer Support Center September 1993
Written by: Developer Support Center December 1992

This Technical Note contains a collection of archived Q&As relating to a specific topic--questions sent the Developer Support Center (DSC) along with answers from the DSC engineers. Current Q&A's can be found on the Macintosh Technical Q&A's web site.


Disabling Macintosh force quit option

Date written: 9/15/92

Last reviewed: 6/14/93

Is there a way to disable the force quit option from System 7?

___

The force quit is handled by calling SysErr with an error code (or selector) of 20002 (Ox4E22). The error code is passed in register D0. A simple patch to this trap, and a check for that selector will allow you to abort its function:

***************************** DontForceQuit *****************************

            INCLUDE          'traps.a'
            INCLUDE          'SysEqu.a'
            INCLUDE          'SysErr.a'

kSysError   EQU $A9C9

PatchIt     PROC             EXPORT     ;Apps invoke this by calling PATCHIT() in C;

            IMPORT           MySysError      ;Trap patch code
            IMPORT           OldSysError     ;Pointer to original Trap Code

; This trap patcher leaves the patch in the app heap
; it will be unpatched when the app quits. For a persistent
; patch, the patch must be installed at INIT time in the system heap

            lea              OldSysError,a1  ;get the address of the pointer saver
            move.w           #kSysError,d0   ;now get address of SysError routine
            _GetTrapAddress  ,NEWTOOL
            move.l           a0,(a1)         ;save it for later
            move.w           #kSysError,d0   ;set up trap num
            lea              MySysError,a0   ;set up new trap address
            _SetTrapAddress  ,NEWTOOL        ;install the patch
            rts                              ;exit

            ENDP

MySysError  PROC             EXPORT

            IMPORT           OldSysError

            cmpi.w           #20002,d0        ;first, check for the right selector
            bne.s            PassItOn         ;if not ours, let the real SysError have it
            rts                               ;if selector matches, return to sender
PassItOn
            move.l           OldSysError,-(sp) ;leave all registers unmolested
            rts

            ENDP

OldSysError PROC             EXPORT

            DC.L             0

            ENDP
            END




Tech Support
Technotes
Previous Technote | Contents


Navigation graphic, see text links

Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help